home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / LEDA / prog / dict / hash_dic.c < prev    next >
C/C++ Source or Header  |  1994-08-05  |  360b  |  24 lines

  1. #include <LEDA/hash.h>
  2.  
  3.  
  4. int hash_fun(const string& x) { return int(x[0]); }
  5.  
  6. main()
  7. {
  8.   hash<string,int> D(hash_fun);
  9.  
  10.   hash_item it;
  11.   string r;
  12.  
  13.   while (cin >> r)
  14.     { it = D.lookup(r);
  15.       if (it==nil) D.insert(r,1);
  16.       else D.change_inf(it,D.inf(it)+1);
  17.      }
  18.  
  19.   forall_items(it,D) cout <<  D.inf(it) << " " << D.key(it) << "\n";
  20.  
  21.   return 0;
  22. }
  23.  
  24.